import React from 'react';

import { connect } from 'dva';

import { Card, Divider, Button } from 'antd';

import OrgEdit from './OrgEdit'


import DescriptionList from '@/components/DescriptionList';
const { Description } = DescriptionList;


@connect(({ partnerOrgModel }) => ({ partnerOrgModel }))
class Profile extends React.Component {
  state = {
     qrcode: null
  }

  async componentDidMount() {
    const { location: {query: { id } } } = this.props;
    if (id) {
      const { dispatch } = this.props;
      dispatch({
        type: 'partnerOrgModel/view',
        payload:  { id: Number(id) }
      });
    }
  }


  showForm() {
    const { dispatch } = this.props;
    dispatch({
      type: 'partnerOrgModel/show',
      payload: 'editForm'
    });

  }

  render() {
    const { partnerOrgModel: { record } } = this.props;

    console.log(record)

    return (
      <Card bordered={false}>

        <DescriptionList size="large" title='操作控制' style={{ marginBottom: 32 }}>
          <Description >
            <Button onClick={()=>this.showForm()}>分享</Button>
          </Description>

        </DescriptionList>

        <OrgEdit
          dataSource = {record}
        >
        </OrgEdit>


        <DescriptionList size="large" title='基本信息' style={{ marginBottom: 32 }}>
          <Description term='名称' >{record.name}</Description>
          <Description term='二维码位置' >{record.ref}</Description>
        </DescriptionList>
        <Divider style={{ marginBottom: 32 }} />
        <DescriptionList size="large" title='图片' style={{ marginBottom: 32 }}>

            <img
              src={`data:image/jpeg;base64,${escape(record.image)}`}
              alt="example"
              style={{width: '30%',height:'30%' }}
            />

        </DescriptionList>
      </Card>
    );
  }
}

export default Profile;


